
var dbg=console.log;
var fs=require("fs");
function runCommentTestAfterFile(filename){
	var filedata="";
	fs.readFile(filename, "utf-8", function(err, data){
		if (err){
			console.error(err);
		}else{
			filedata += data;
		}
		runCommentTestAfterCompile(filedata);
	});
}

function runCommentTestAfterCompile(filedata){
	eval(filedata);
	fileLines = filedata.split("\n");
	var rundata="";
	fileLines.forEach(function(line, index, array){
		line=line.trimLeft();
		if (line.substr(0,3) == "//T"){
			rundata += line.substr(3);
		}else{
			if (rundata!=""){
				// dbg("Program Runs:" + rundata + "\nProgram Ends.\n");
				eval(rundata);
				rundata="";
			}
		}
	});

	if (rundata!=""){
		eval(rundata);
		rundata="";
	}
}

process.argv.forEach(function(val, index, array){
	if (index>1){
		runCommentTestAfterFile(val);
	}
});



